/* Copyright (c) [2024] [ylc]. Licensed under Apache-2.0 License. */

#ifndef __MY_DIS188_H
#define __MY_DIS188_H

#include "my_define.h"

//IO输入
#define DIS1_IN		P0CON&=~(1<<0)
#define DIS2_IN		P0CON&=~(1<<1)
#define DIS3_IN		P0CON&=~(1<<5)
#define DIS4_IN		P2CON&=~(1<<5)
#define DIS5_IN		P2CON&=~(1<<6)

//IO输出
#define DIS1_L		P0CON|= (1<<0);P00=0
#define DIS2_L		P0CON|= (1<<1);P01=0
#define DIS3_L		P0CON|= (1<<5);P05=0
#define DIS4_L		P2CON|= (1<<5);P25=0
#define DIS5_L		P2CON|= (1<<6);P26=0

#define DIS1_H		P0CON|= (1<<0);P00=1
#define DIS2_H		P0CON|= (1<<1);P01=1
#define DIS3_H		P0CON|= (1<<5);P05=1
#define DIS4_H		P2CON|= (1<<5);P25=1
#define DIS5_H		P2CON|= (1<<6);P26=1


typedef union{
	struct{
		//com1
		u8 A1:1;
		u8 B1:1;
		u8 C1:1;
		u8 D1:1;
		u8 E1:1;
		u8 F1:1;
		u8 G1:1;
		u8 H1_bak:1;
		
		//com2
		u8 A2:1;
		u8 B2:1;
		u8 C2:1;
		u8 D2:1;
		u8 E2:1;
		u8 F2:1;
		u8 G2:1;
		u8 H2_bak:1;
		
		//com3
		u8 A3:1;
		u8 B3:1;
		u8 C3:1;
		u8 D3:1;
		u8 E3:1;
		u8 F3:1;
		u8 G3:1;
		u8 H3_bak:1;
		
		//com4
		u8 L1:1;
		u8 L2:1;
		u8 L3:1;
		u8 L4:1;
		u8 L5:1;
		u8 L6:1;
		u8 L7:1;
		u8 L8:1;
	}led;
	struct{
		u8 A:1;
		u8 B:1;
		u8 C:1;
		u8 D:1;
		u8 E:1;
		u8 F:1;
		u8 G:1;
		u8 H:1;
	}b[4];
	u8 buf[4];
}DT_SEG_T;

extern DT_SEG_T DT_SEG;
extern u8 dt_buf[10];

void dis188_init(void);
void dis188_500us(void);
void dis188_display(u16 num,u8 unit);

#endif